<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        class Person {
            constructor() {}; // 构造函数，调用new 自动执行
            get aaa() {
                return `aaa的属性`
            }
            set aaa(val) {
                console.log(`设置aaa的值为${val}`);
            }
        };

        let p1 = new Person();
        p1.aaa = '1234' // 设置属性
        console.log(p1.aaa); //获取属性
    </script>
</body>

</html>